package com.cy.util;

import com.alibaba.fastjson.JSON;
import com.cy.pojo.Price;

import java.util.Comparator;

/**
 * Created by PVer on 2017/7/21.
 */
public class PriceComparator implements Comparator {


    @Override
    public int compare(Object o1, Object o2) {
        Price q1 = (Price) o1;
        Price q2 = (Price) o2;
        try {
            return BigDecimalUtil.isBig(BigDecimalUtil.sub(BigDecimalUtil.mul(q2.getTicker().getVol(), BigDecimalUtil.div(BigDecimalUtil.add(q2.getTicker().getLow(), q2.getTicker().getHigh()), "2", 4)),
                    BigDecimalUtil.mul(q1.getTicker().getVol(), BigDecimalUtil.div(BigDecimalUtil.add(q1.getTicker().getLow(), q1.getTicker().getHigh()), "2", 4))), "0");
        } catch (IllegalAccessException e) {
            return -1;
        }
    }
}
